@/*
    表单中inputTree框标签中各个参数的说明:
    id : input框id
    name : input框名称
    value : value
    textValue :textValue
    placeholder:placeholder
    style : 附加的css属性
    width: 自定义宽默认100%
    url : 树地址
@*/
@if(isEmpty(width)){
@	width="100%";
@}
<div class="form-group">
    @if(!isEmpty(name)){
    <label class="lab">${name!}</label>
    @}
    <div class="ele ${isEmpty(name)?'ele-fit':''}">
        <input class="textbox" id="${id}_text" name="${id}_text" style="width:${width!}"
               @if(isNotEmpty(style)){
                    style="${style}"
               @}
               @if(isNotEmpty(placeholder)){
                    placeholder="${placeholder}"
               @}
               readonly="readonly"
               type="text"
               onclick="showSelectTree_${id}()"
               value="${textValue!}"
        >
        <input type="hidden" id="${id}" name="${id}" value="${value!}">
        <div id="pTreeDiv_${id}" style="display: none; position: absolute; z-index: 200;">
            <ul id="pTree_${id}" class="ztree tree-box" style="${selectStyle!}"></ul>
        </div>
		@if(isNotEmpty(tips)){
	        <span class="help-block m-b-none">${tips!}</span>
		@}
    </div>
</div>
@if(isNotEmpty(underline) && underline == 'true'){
    <div class="hr-line-dashed"></div>
@}
<script>
var ztree_${id};
var showSelectTree_${id} = function() {
    Sys.showInputTree("${id}_text", "pTreeDiv_${id}", 15, 28);
}
var onClick_${id} = function(e, treeId, treeNode) {
	if($("#id")&&$("#id").val()==treeNode.id&&treeNode.id!=0){
		Sys.error("不要选自己啦！")
		return;
	}
    $("#${id}_text").attr("value", ztree_${id}.getSelectedVal());
    $("#${id}").attr("value", treeNode.id);
};
$(function() {
    ztree_${id} = new $ZTree("pTree_${id}", Sys.backendPath + "${url!}");
    ztree_${id}.bindOnClick(onClick_${id});
    ztree_${id}.init();
});
</script>

